//
// Created by Jisam on 05/10/2024 19:03.
// Solution of  b
#include <bits/stdc++.h>

#define  int long long
#define  endl "\n"
using namespace std;


signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int t,n;
    cin >> t>>n;

    vector<int> a(n);
    for(int i = 0 ; i < n ; i ++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int l = 0,r = n -1;
    int ans = 0;
    while(l <= r){
        if(a[l]+a[r]<=t)   //一定要有等号。
            l++,r--,ans++;
        else
            r--,ans++;   //贪心过程
    }
    cout << ans;
    return 0;
}